'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Point = function () {
    function Point() {
        var _this = this;

        _classCallCheck(this, Point);

        this.fun = function () {
            console.log(_this.name() + ' fun from point');
        };

        this.foo = this.foo.bind(this);
    }
    //普通方式定义的类方法，转码后是，是作为类实例的__proto__
    //普通方式定义的类方法，是定义在类的prototype上


    _createClass(Point, [{
        key: 'foo',
        value: function foo() {
            var classname = this.name();
            console.log(classname + ' foo from point');
        }
        //箭头函数，使用babel-preset-stage-2可进行转码
        //类方法的箭头函数，通过babel转码后，是作为类实列的属性方法声明
        //类方法的箭头函数，直接定义在类的里面，默认绑定this

    }, {
        key: 'name',
        value: function name() {
            return 'class name is point';
        }
    }]);

    return Point;
}();

// export default Point


var instancePoint = new Point();
//instancePoint.foo();
var foo = instancePoint.foo,
    fun = instancePoint.fun;

fun();